package zuoye07;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class zuoye04 {
     public static void main(String[] args) {
          Map<String,Integer> map=new HashMap<>();
          File file = new File("E:\\bilibili");
         map=aaa(file,map);
         System.out.println(map);
         for(Map.Entry<String,Integer> entry:map.entrySet()){
              System.out.println(entry.getKey()+":"+entry.getValue()+"个");
         }
     }
     public static Map<String,Integer> aaa(File file, Map<String,Integer> map ) {

          File[] files = file.listFiles();
          for (File f : files) {
               if (f.isDirectory()) {
               aaa(f,map);}
               if (f.isFile()) {
                    String name = f.getName();
                    String name_1 = name.split("\\.")[name.split("\\.").length - 1];
                    if (map.containsKey(name_1)) {
                         map.put(name_1, map.get(name_1) + 1);
                    } else {
                         map.put(name_1, 1);
                    }
          }
}
          return map;
     }
}
